#pragma  once
#include "stdafx.h"
#include "Ball_3d.h"
#include "unarchived.h"
#include "Configuration.h"
class Flock{
public:

	Ball_3D* bird;

	Ball_3D* center;

	unsigned int* color;

	set<int>* grid;

	double alignmentStrength;

	int alignmentType;

	int boundaryType;

	bool clusteringEnabled;

	double cohesionStrength;

	int cohesionType;

	bool gridEnabled;

	double initRange;

	double lambda;

	int nBirds;

	int nClusters;

	int neighborNum;

	double neighborRange;

	int nGrids;

	int noiseType;

	double noiseLevel;

	double systemSize;

	double timeStep;

	double c_rb;
	double c_ra;
	double c_re;
	double c_rS;
	double c_aS;

public:
	Flock( );

	Flock( Configuration& );

	~Flock();

	void addIntrinsicNoise( );

	void boundary( );

	inline double distance(Ball_3D*, Ball_3D*);

	Vector_3D* getAlignmentForce();

	Vector_3D* getCohesionForce();

	Vector_3D* getExtrinsicNoise();

	int*  getNearestNeighbors(int id);

	int* getNearestNeighbors_Full(int id);

	set<int> getNeighborId(int id);

	set<int> getNeighborId_Full(int id);

	bool init();

	bool initCluster();

	bool initPV();

	bool initPV2();

	void kmeans( );

	void mapToGrid();

	void move();	

	int nearestCenter(int );

	inline Vector_3D pairCohensionForce(Ball_3D&, Ball_3D&); //second to first

	inline Vector_3D pairAlignmentForce(Ball_3D&, Ball_3D&);

	void setConfiguration( Configuration & );

	void updatePosition();

	void updateVelocity();

public:
	bool specialInit();
	void specialUpdateSpeed();
	inline double quasiDistance(Ball_3D*, Ball_3D*);
};




